-
-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce Body Limit Middleware using stream #2103
Conversation
Co-authored-by: Ame_x <[email protected]>
Express has an effortless way to customize its body limit, defaulting to 100kb max. |
…2109) * fix(body-limit): fix typo * feat(body-limit): Replace `c.req.raw` with body limit middleware proxy * refactor(body-limit): we can trust content-length header * fix(body-limit): call controller.error instead of throwing an error * test(body-limit): add test for ReadableStream body * chore: denoify * refactor(middleware/body-limit): throw HTTPException instead of retuning c.text()
Hey @usualoma Could you review this merged code again? |
Do we need data called
|
Personally, I have the above opinion about the current specifications of |
(A few updated implementation examples) |
Thanks, @usualoma ! As for Unit, I think removing it might be a good idea. I agree with the following opinion.
|
All works are finished! @EdamAme-x If you are okay, I'll merge this PR to the "next" with you as a co-author! |
@yusukebe Thank you! |
You are right. Updated! |
Hi @EdamAme-x! Now, I'll merge this into the "next". Thanks a lot! |
Oops. Mistook. Merged into the main. Reverting. |
This is an implementation of the feature proposed in #2077 using stream.
How to use
Simply specify the maximum size.
Using stream
The problem discussed in #2077 that a body must be read at a time is solved by using stream.
c.req.bodyCache
It uses
c.req.bodyCache
used by the Validator implementation. By setting the loaded ArrayBuffer toc.req.bodyCache.arrayBuffer
, such asc.req.json()
will use that cached body from then on.Author should do the followings, if applicable
yarn denoify
to generate files for Deno